﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;



namespace DataCapture.Helper
{
    public class PublicHelp
    {
        public static Dictionary<int, List<ActionAddressConfig>> ActionAddressConfigs = new Dictionary<int, List<ActionAddressConfig>>();   //PLC动作信息表
        public static Dictionary<int, List<AlarmAddressConfig>> AlarmAddressConfigs = new Dictionary<int, List<AlarmAddressConfig>>();    //PLC告警信息表


        public static List<PublicHelp.PlcData> PlcDataList = new List<PublicHelp.PlcData>();//PLC数据表
        public static Dictionary<string, bool> DeviceRunFlag = new Dictionary<string, bool>(); //plc设备运行状态


        public static int DeviceNum { get; set; }//plc设备个数
        public struct DeviceData<T>
        {
            public long timeStamp;
            public string deviceId;         //设备id
            public string dataType;         //动作Action、告警Alarm、当前设备生产数据Report
            public T data;                  //数据内容
        }

        //设备类型
        public enum deviceType
        {
            RXJ = 0,       //绕线机
            XCCLJ = 1,     //线材处理机
            ZJFFJ = 2,     //载具分发机
            JSZSJ = 3,     //胶塞注塑机
            XPMJJ = 4,     //芯片铆接机
            JCGSLJ = 5,    //基础管上料机
            KKJ = 6,       //卡口机
            ZDZDJ = 7,     //自动装袋机
                           
            Report = 8,    //数据报表统计
        }
        public enum DeviceType
        {

            RXJ = 0,    //绕线机
            FXJ,        //放线机
            XCCLJ,      //线头处理及下盖组装机
            ZJFFJ,      //载具分发机
            RGPMJ,      //人工排模机
            JSZSJ,      //胶塞注塑机
            XXBPJCJ,    //芯线剥皮检测机
            XPMJJ,      //芯片铆接机
            XPJCJ,      //芯片通电检测机
            JGJC,       //激光焊接检测机
            LMTSJ,      //龙门提升机
            JCGSLJ,     //基础管上料机
            KKJ,        //卡口机
            ZDTBJ,     //自动剔补机
            JGDMZSGJ,   //激光打码机
            ZGZZSG,     //注硅脂机及上盖组装机
            ZDZDJ,        //装袋机
            KXJ,        //开箱机
            ZXTBJ,        //装箱贴标机
            SMSFZJ,     //说明书放置机
            FXDDJ,        //封箱口机
            DBJ,        //打包机
            TBJ,         //踏步机
            JXS,         //机械手
            LongBelt,
            JXSZPJ//组批间机械手
        }
        //MQTT协议的数据类型
        public enum dataType
        {
            Action = 0,
            Alarm,
            Report
        }
        //MQtt的topic
        static readonly public string[] Topics = { 
            "RXJ_1", "RXJ_2", "RXJ_3", "RXJ_4", "RXJ_5", "RXJ_6", "RXJ_7", "RXJ_8",
            "XCCLJ_1", "XCCLJ_2", 
            "ZJFFJ_1", 
            "JSZSJ_1", "JSZSJ_2",  
            "XXBPJCJ_1", "XXBPJCJ_2",
            "XPMJJ_1", "XPMJJ_2",
            "JGJC_1", "JGJC_2",
            "LMTSJ_1",
            "JCGSLJ_1",
            "KKJ_1", "KKJ_2", 
            "ZDTBJ_1", "ZDTBJ_2",
            "JGDMZSGJ_1", "JGDMZSGJ_2", 
            "ZDZDJ_1", "ZDZDJ_2", 
            "ZXTBJ_1", "ZXTBJ_2"
        };

        //所PLC设备ID
        static readonly public string[] AllPLC_Id = { "RXJ_1", "XCCLJ_1", "XCCLJ_2", "ZJFFJ_1", "JSZSJ_1", "JSZSJ_2",  "XPMJJ_1", "XPMJJ_2", "JCGSLJ_1",  "KKJ_1", "KKJ_2", "ZDZDJ_1", "ZDZDJ_2" };

        //8台绕线机的设备代号
        static readonly public string[] RXJ_PLC_Id = { "RXJ_1", "RXJ_2", "RXJ_3", "RXJ_4", "RXJ_5", "RXJ_6", "RXJ_7", "RXJ_8" };

        //2台线材处理机的设备代号
        static readonly public string[] XCCLJ_PLC_Id = { "XCCLJ_1", "XCCLJ_2" };

        //1台线载具分发机的设备代号
        static readonly public string[] ZJFFJ_PLC_Id = { "ZJFFJ_1" };
        //1台龙门提升机的设备代号
        static readonly public string[] LMTSJ_PLC_Id = { "LMTSJ_1" };

        //2台胶塞注塑机、剥皮裁切检测机的设备代号     
        static readonly public string[] JSZSJ_PLC_Id = { "JSZSJ_1", "JSZSJ_2" };

        //2台芯片铆接机、激光焊接检测的设备代号       
        static readonly public string[] XPMJJ_PLC_Id = { "XPMJJ_1", "XPMJJ_2" };

        //1台基础管上料机的设备代号
        static readonly public string[] JCGSLJ_PLC_Id = { "JCGSLJ_1" };

        //2台卡口机、不良品替补、激光打码装上盖的设备代号
        static readonly public string[] KKJ_PLC_Id = { "KKJ_1", "KKJ_2"};

        //2台自动装袋机、装箱贴标机的设备代号
        static readonly public string[] ZDZDJ_PLC_Id = { "ZDZDJ_1", "ZDZDJ_2" };

        #region Action实体类


        public struct RXJ_PLC_ActionDataModel
        {

            public bool NX_XZ_1 { get; set; }
            public bool NX_XZ_2 { get; set; }
            public bool Belt_Up_1 { get; set; }//倍速链

            public bool StartBlock_1 { get; set; }//起始点阻挡
            public bool StartBlock_2 { get; set; }
            public bool StartSensor_1 { get; set; }//起始点感应器
            public bool StartSensor_2 { get; set; }

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2{ get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
          
            

            public bool NX_JZ_1 { get; set; }
            public bool NX_UpDown_1 { get; set; }
            public bool NXJZ_JZ_1 { get; set; }
            public bool NXJZ_LDJZ_1 { get; set; }
            public bool NXJZ_SS_1 { get; set; }
            public bool ZX_UpDown_1 { get; set; }
            public bool ZX_JZ_1 { get; set; }
            public bool ZX_SS_1 { get; set; }
            public bool ZX_LXJZ_1 { get; set; }
            public bool CX_UpDown_1 { get; set; }
            public bool CX_JZ_1 { get; set; }
            public bool RX_UpDown_1 { get; set; }
            public bool RX_UpDown_2 { get; set; }
            public bool RX_JZ_1 { get; set; }
            public bool RX_JZ_2 { get; set; }



            public int PX_UpDown_1 { get; set; }
            public int HJ_V_1 { get; set; }
            public int HJ_H_1 { get; set; }
            public int NX_Move_1 { get; set; }
            public int RX_XZ_1 { get; set; }
            public int RX_XZ_2 { get; set; }
           
            public int PX_UpDown_2 { get; set; }
            public int HJ_V_2 { get; set; }
            public int HJ_H_2 { get; set; }
            public int NX_Move_2 { get; set; }

            public bool NX_JZ_2 { get; set; }
            public bool NXJZ_JZ_2 { get; set; }
            public bool NXJZ_SS_2 { get; set; }
            public bool NX_LDJZ_2 { get; set; }
            public bool NX_UpDown_2 { get; set; }
            public bool ZX_UpDown_2 { get; set; }
            public bool ZX_JZ_2 { get; set; }
            public bool ZX_SS_2 { get; set; }
            public bool ZX_LXJZ_2 { get; set; }
            public bool CX_UpDown_2 { get; set; }
            public bool CX_JZ_2 { get; set; }

            public bool TZJ_Up_1 { get; set; }
            public bool TZJ_Up_2 { get; set; }
            public bool TZJ_Down_1 { get; set; }
            public bool TZJ_Down_2 { get; set; }
            public bool ZJ_TSJ_1 { get; set; }
            public bool ZJ_TSJ_2 { get; set; }
            public bool ZJ_DW_1 { get; set; }
            public bool ZJ_DW_2 { get; set; }
            public bool ZJ_TJ_1 { get; set; }
            public bool ZJ_TJ_2 { get; set; }
            public bool ZJDS_Up_1 { get; set; }
            public bool ZJDS_Up_2 { get; set; }
            public bool ZJDS_Down_1 { get; set; }
            public bool ZJDS_Down_2 { get; set; }



        }

        //线材处理机
        public struct XCCLJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2 { get; set; }//装上盖-倍速链2
            public bool Belt_Up_3 { get; set; }//装上盖-倍速链3

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
            public bool Block_6 { get; set; }
            public bool Block_7 { get; set; }
            public bool Block_8 { get; set; }
            public bool Block_9 { get; set; }
            public bool Block_10 { get; set; }
            public bool Block_11 { get; set; }
            public bool Block_12 { get; set; }
            public bool Block_13 { get; set; }
            public bool Block_14 { get; set; }
            
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
            public bool Sensor_6 { get; set; }
            public bool Sensor_7 { get; set; }
            public bool Sensor_8 { get; set; }
            public bool Sensor_9 { get; set; }
            public bool Sensor_10 { get; set; }
            public bool Sensor_11 { get; set; }
            public bool Sensor_12 { get; set; }
            public bool Sensor_13 { get; set; }
            public bool Sensor_14 { get; set; }
           

            public bool XZJ_DS { get; set; }//旋转机-顶升
            public bool JB_UpDown_1 { get; set; }            //接驳装置-顶升1
            public bool JB_UpDown_2 { get; set; }            //接驳装置-顶升2
            public bool JB_UpDown_3 { get; set; }            //接驳装置-顶升3
            public bool JB_UpDown_4 { get; set; }            //接驳装置-顶升4
            public bool JB_UpDown_5 { get; set; }            //接驳装置-顶升5
            public bool JB_UpDown_6 { get; set; }            //接驳装置-顶升6
            public bool JB_SS { get; set; }                  //进接驳气缸V01
            public bool JB_UpDown { get; set; }              //接驳顶升气缸V02
            public bool LV_YX { get; set; }                  //A捋线压线气缸V03
            public bool LV_JX { get; set; }                  //A捋线夹线上气缸
            public bool LV_LX { get; set; }                  //A捋线拉线气缸V05
            public bool BP_YX_R { get; set; }                  //A剥皮压线气缸
            public bool BP_TJ_R { get; set; }                  //A剥皮托举气缸
            public bool BP_SD_R { get; set; }                  //A剥皮上刀气缸
            public bool BP_XD_R { get; set; }                  //剥皮装置-右下刀
            public bool BP_HL_R { get; set; }                  //A剥皮后拉气缸
            public bool BP_XDZC_R { get; set; }                //A剥皮下刀支撑气缸
            public bool BP_YXP_R { get; set; }                //A剥皮压线皮气缸
            
            public bool BP_YX_L { get; set; }                  //B剥皮压线气缸
            public bool BP_TJ_L { get; set; }                  //B剥皮托举气缸
            public bool BP_SD_L { get; set; }                  //B剥皮上刀气缸
            public bool BP_XD_L { get; set; }                  //B剥皮装置-右下刀
            public bool BP_HL_L { get; set; }                  //B剥皮后拉气缸
            public bool BP_XDZC_L { get; set; }                //B剥皮下刀支撑气缸
            public bool BP_YXP_L { get; set; }                //B剥皮压线皮气缸


            public bool FX_YX_R { get; set; }                  //A分线右压线
            public bool FX_TJ_R { get; set; }                  //A分线托举气缸
            public bool FX_CX_R { get; set; }                  //A分线右戳线
            public bool FX_QT_R { get; set; }                  //A分线前推
            public bool FX_ZY_R { get; set; }                  //A分线左右
            public bool FX_SDW_R { get; set; }                  //A分线压线
            public bool FX_XDW_R { get; set; }                  //A分线顶升
            public bool FX_QD_R { get; set; }                  //A分线前顶

            public bool FX_YX_L { get; set; }                  //B分线右压线
            public bool FX_TJ_L { get; set; }                  //B分线托举气缸
            public bool FX_CX_L { get; set; }                  //B分线右戳线
            public bool FX_QT_L { get; set; }                  //B分线前推
            public bool FX_ZY_L { get; set; }                  //B分线左右
            public bool FX_SDW_L { get; set; }                  //B分线压线
            public bool FX_XDW_L{ get; set; }                  //B分线顶升
            public bool FX_QD_L { get; set; }                  //B分线前顶

            public bool CQ_SD_R { get; set; }                  //A裁切上刀
            public bool CQ_XD_R { get; set; }                  //A裁切上刀
            public bool CQ_SDZC_R { get; set; }              //A裁切下刀支撑
            public bool CQ_SD_L { get; set; }                  //B裁切上刀
            public bool CQ_XD_L{ get; set; }                  //B裁切上刀
            public bool CQ_SDZC_L{ get; set; }              //B裁切下刀支撑

            public bool ZXG_YH_1 { get; set; }               //A1装下盖压合
            public bool ZXG_DS_1 { get; set; }               //A1装下盖顶升
            public bool ZXG_XY_1 { get; set; }               //A1装下盖下压气缸
            public bool ZXG_TL_1 { get; set; }               //A1装下盖推料气缸V48
            public bool ZXG_ZDTL_1 { get; set; }             //A1推料气缸V49
            public bool NX_GD_1 { get; set; }                //B1扭线固定气缸V51
            public bool NX_DS_1 { get; set; }                //B1扭线夹爪顶升气缸V52
            public bool NX_HL_1 { get; set; }                //B1扭线回拉气缸V53
            public bool NX_ZJ_1 { get; set; }                //B1扭线夹爪气缸V54
            public bool ZXG_YH_2 { get; set; }               //A2装下盖压合气缸V55
            public bool ZXG_DS_2 { get; set; }               //A2装下盖顶升气缸1V56
            public bool ZXG_XY_2 { get; set; }               //A2装下盖下压气缸V57
            public bool ZXG_TL_2 { get; set; }               //A2装下盖推料气缸V58
            public bool ZXG_ZDTL_2 { get; set; }             //A2推料气缸V59
            public bool ZXG_UpDown_1 { get; set; }             //装下盖装置-顶升
            public bool ZXG_UpDown_2 { get; set; }             //装下盖装置-顶升


            public bool NX_GD_2 { get; set; }                //B2扭线固定气缸V61
            public bool NX_DS_2 { get; set; }                //B2扭线固定顶升气缸V62
            public bool NX_HL_2 { get; set; }                //B2扭线回拉气缸V63
            public bool NX_ZJ_2 { get; set; }                //B2扭线夹爪气缸V64
            public bool NG_Move { get; set; }                //NG取载具平移气缸V65
            public bool NG_UpDown { get; set; }              //NG取载具升降气缸V66
            public bool NG_JZ { get; set; }                  //NG取载具夹爪气缸V67
            public bool JC_UpDown { get; set; }              //下盖托举气缸V68
            public bool JC_FZJ { get; set; }                 //出料分载具气缸V69
            public bool JC_DB { get; set; }                  //出料阻挡气缸V70


            public int NX_NX_1 { get; set; }                 //B1扭线步进
            public int NX_NX_2 { get; set; }                 //B2扭线步进
            public int CCD_Move { get; set; }                //相机伺服
            public int TBJ_Move { get; set; }                //踏步机移栽
            public int TBJ_XZ { get; set; }                 //踏步移栽-旋转


        }

        //载具分发机
        public struct ZJFFJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//插线-倍速链1
            public bool Belt_Up_2 { get; set; }//载具分发-倍速链1

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
           

            public bool ZJFF_Up_DS{ get; set; }           //A上层顶升载具气缸（V05）
            public bool ZJFF_Up_FL{ get; set; }              //A上层推载具气缸（V06）
            public bool ZJFF_Up_DW{ get; set; }             //A-B上层推载具平移气缸（V10）
            public bool ZJFF_Down_DS{ get; set; }          //A-B上层推载具升降气缸（V11）
            public bool ZJFF_Down_FL{ get; set; }             //B上层阻挡气缸1（V20）
            public bool ZJFF_Down_DW{ get; set; }           //B上层顶升气缸（V21）

        }

        //胶塞注塑机
        public struct JSZSJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
          

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            

            public bool TB_UpDown_1{ get; set; }             //踏步顶升气缸1(双控)
            public bool TB_UpDown_2{ get; set; }             //踏步顶升气缸2(双控)
            public bool TB_UpDown_3{ get; set; }             //踏步顶升气缸3(双控)
            public int TB_Move{ get; set; }                  //载具输送伺服
           
           
        }


        //剥皮裁切检测机
        public struct XXBPJCJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
           

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
           

            public bool CQ_ZJDS{ get; set; }                 //裁切工位载具顶升气缸
            public bool JC_ZJDS{ get; set; }                 //检测载具顶升气缸
            public bool CQ_JZDS{ get; set; }                 //裁切夹爪顶升气缸
            public bool CQ_XD{ get; set; }                 //裁切下压定位气缸
            public bool CQ_XY{ get; set; }                 //裁切下压气缸
            public bool CQ_DS{ get; set; }                 //裁切顶升气缸
            public bool CQ_ZC{ get; set; }                 //裁切底部支撑气缸
            public bool CQ_HL{ get; set; }                 //裁切后拉气缸（双控）
            public bool CQ_HD{ get; set; }                  //CCD定位夹爪气缸
            public bool JC_JZ{ get; set; }                  //CCD定位夹爪顶升气缸
            public bool JC_DS{ get; set; }               //NG载具夹取升降气缸(双控)
            public bool NG_Move{ get; set; }               //不良品搬运-平移
            public bool NG_UpDown{ get; set; }             //不良品搬运-升降
            public bool NG_JZ{ get; set; }                 //不良品搬运-夹爪
            public int CCD_Move{ get; set; }                //CCD检测伺服

           

        }

        //芯片铆接
        public struct XPMJJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
            public bool Block_1 { get; set; }//阻挡
            public bool Sensor_1 { get; set; }//感应器
          
            public bool XPZJ_DW{ get; set; }               //1#上料载具定位气缸V01
            public bool XPZJ_GD{ get; set; }               //1#上料载具固定气缸V02
            public bool XPTL_TL{ get; set; }               //1#推拉工装气缸V03
            public bool XPTL_JZ{ get; set; }               //1#推拉工装夹爪气缸V04
            public bool XPTL_DW{ get; set; }               //1#工装定位气缸V05
            public bool QL_UpDown{ get; set; }             //1#取满料升降气缸V06
            public bool QL_DW{ get; set; }                 //1#取满料夹爪气缸V07
            public bool QL_ZJ{ get; set; }             //1#取空料升降气缸V08
            public bool CQ_Move{ get; set; }                 //1#取空料夹爪气缸V09
            public bool CQ_GD{ get; set; }               //1#取芯片平移气缸V10
            public bool CQ_CQ{ get; set; }               //1#取芯片平移气缸V10
            public bool ZC_XY{ get; set; }               //1#取芯片平移气缸V10
            public bool BJQL_JZ{ get; set; }                 //1#取芯片整边气缸V11
            public bool XPSS_JZ{ get; set; }                 //1#芯片整形气缸V12
            public bool XPSS_UpDown{ get; set; }               //1#变距取料气缸1V13
            public bool XPSS_Move{ get; set; }               //1#定位夹爪气缸V17
            public bool XPMY_JZ{ get; set; }           //1#上芯片顶升气缸V18
            public bool XPMY_UpDown{ get; set; }             //1#上芯片输送气缸V19
            public bool ZJ_DS{ get; set; }               //1#左合模夹爪气缸V20
            public bool ZJ_DW{ get; set; }           //1#合模升降气缸V21
          
           
            public int LH_MoveZ{ get; set; }               //1#料盒升降轴
            public int QL_MoveY{ get; set; }               //1#取芯片平移Y轴A
            public int QL_MoveX{ get; set; }               //1#取芯片平移X轴A
            public int JQ_MoveY{ get; set; }               //1#取芯片平移Y轴B
            public int JQ_MoveZ{ get; set; }               //1#取芯片Z轴
            public int JQ_MoveX{ get; set; }               //1#取芯片变距X
            public int ZC_MoveX{ get; set; }                //1#取料模组X轴
            
           

        }

        //激光检测
        public struct JGJC_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2 { get; set; }//装上盖-倍速链2
            public bool Belt_Up_3 { get; set; }//装上盖-倍速链3

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
            

            public bool HJ_ZJDS{ get; set; }                  //焊接载具顶升气缸伸出V6
            public bool HJ_JJDS{ get; set; }                  //CCD检测顶升气缸伸出V7
            public bool HJ_LRJJ{ get; set; }                  //焊接检测左右气缸伸出V8
            public bool JC_ZJDS{ get; set; }                  //焊接检测顶升气缸伸出V9
            public bool JC_JJDS{ get; set; }                  //顶升固定气缸伸出V10
            public bool JC_LRJJ{ get; set; }                  //下压固定气缸伸出V11
            public bool DXJC_DS{ get; set; }                  //侧推定位气缸伸出V12
            public bool DXJC_TZXY{ get; set; }                //探针下压检测气缸V13
            public bool NG_Move{ get; set; }                  //NG平移气缸伸出V14（双线圈）
            public bool NG_UpDown{ get; set; }                //NG升降气缸缩回V15（双线圈）
            public bool NG_JZ{ get; set; }                    //NG夹取气缸伸出V16（双线圈）
            public int JGHJ_MoveX{ get; set; }                //激光焊接平移X轴
            public int CCD_Move{ get; set; }                  //激光焊接CCD检测轴
            public int ZJ_Up_Move{ get; set; }                //激光焊接CCD检测轴
            public int ZJ_Down_Move{ get; set; }              //激光焊接CCD检测轴
            public int HC_TSJ{ get; set; }                    //激光焊接CCD检测轴

            
            public bool Belt_Up{ get; set; }                  //检测载具输送电机启动
            public bool Belt_NG_F{ get; set; }                //NG输送电机正转
            public bool Belt_NG_B{ get; set; }                //NG输送电机反转

        }

        //龙门提升
        public struct LMTSJ_PLC_ActionDataModel
        {
          
            public bool Belt_Up_1 { get; set; }//龙门-左上层倍速链2
            public bool Belt_Up_2 { get; set; }//龙门-上层倍速链3
            public bool Belt_Up_3 { get; set; }//龙门-右上层倍速链4
            

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
           
          
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
            
           

            public bool TSJ_UP_DS{ get; set; }               //龙门输送-上层顶升
            public bool TSJ_BZJ{ get; set; }                 //龙门输送-上层拨载具
            public bool TSJ_Up_DW{ get; set; }               //龙门输送-上层定位
            public bool TSJ_Down_DS{ get; set; }             //龙门输送-下层顶升
            public bool TSJ_TZJ{ get; set; }               //后提升机上层阻挡气缸
            public bool TSJ_Down_DW{ get; set; }            //后提升机下层阻挡气缸
            public bool NG_Move{ get; set; }                //龙门提升机Z轴1#
            public bool NG_UpDown{ get; set; }             //龙门提升机Z轴2#
            public bool NG_JZ{ get; set; }                //龙门提升机Z轴1#运行标志位

            public int TSJ_UpDown_1{ get; set; }              //龙门提升机-升降
            public int TSJ_UpDown_2{ get; set; }              //龙门提升机-升降
            public int CCD_Move{ get; set; }              //插线CCD
            public int HC_UpDown{ get; set; }              //缓存提升

        }

        //基础管上料机
        public struct JCGSLJ_PLC_ActionDataModel
        {
            public bool QLH_UpDown{ get; set; }              //夹取升降气缸
            public bool QLH_JZ{ get; set; }                  //夹取夹爪气缸
            public bool FJLH_UpDown{ get; set; }             //分拣升降气缸
            public bool FJLH_JZ{ get; set; }                 //分拣夹爪气缸
            public bool FJLH_ML_UpDown_1{ get; set; }        //2号满料道隔爆门
            public bool FJLH_KL_UpDown_1{ get; set; }        //3号满料道隔爆门
            public bool FJLH_ML_UpDown_2{ get; set; }        //4号满料道隔爆门
            public bool FJLH_KL_UpDown_2{ get; set; }        //5号满料道隔爆门

            public int SSML_Rota_1{ get; set; }              //D01基础管升降输送轴
            public int SSML_Rota_2{ get; set; }              //D01基础管升降输送轴
            public int SSML_Rota_3{ get; set; }              //D01基础管升降输送轴
            public int SSML_Rota_4{ get; set; }              //D01基础管升降输送轴
            public int SSML_Rota_5{ get; set; }              //D01基础管升降输送轴
            public int SSML_Rota_6{ get; set; }              //D01基础管升降输送轴
            public int SSML_Rota_7{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_1{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_2{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_3{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_4{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_5{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_6{ get; set; }              //D01基础管升降输送轴
            public int SSKL_Rota_7{ get; set; }              //D01基础管升降输送轴
            public int JCGSL_MoveZ{ get; set; }              //D01基础管升降输送轴
            public int JCGSL_MoveX{ get; set; }              //D02龙门移载X轴
            public int JCGSL_MoveY{ get; set; }              //D03龙门移载Y轴
            public int SCFJ_MoveX{ get; set; }               //D04上层分拣X轴
            public int JCGSL_On_Num{ get; set; }             //基础管道总上料数
            public int JCGSL_Surplus_Num{ get; set; }        //基础管道剩余料数
        }

        //卡口机
        public struct KKJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2 { get; set; }//-倍速链2
           

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
           

            public bool HSDW_XZ { get; set; }                //料盒旋转气缸缩回V1   
            public bool HSDW_DS{ get; set; }                 //基础管顶升气缸伸出V2       
            public bool HSDW_DW{ get; set; }                 //基础管左右定位气缸伸出V3 
            public bool JQYW_MS{ get; set; }                 //夹取移位-毛刷气缸
            public bool JQYW_JQ{ get; set; }                 //基础管变距夹取气缸1伸出V4
            public bool JQYW_DW{ get; set; }                 //基础管夹取定位气缸缩回V8
            public bool SK_DWDS{ get; set; }                 //基础管定位顶升气缸伸出V9
            public bool SK_DWXY{ get; set; }                 //基础管定位下压气缸伸出V10
            public bool SK_ZXDS{ get; set; }                 //基础管整形顶升气缸伸出V11
            public bool SK_ZXXY{ get; set; }                 //基础管整形下压气缸伸出V12
            public bool SK_TJCG{ get; set; }                 //推基础管气缸缩回V13
            public bool SK_JCGFD{ get; set; }                //基础管翻斗气缸缩回V14
            public bool SK_SKJ{ get; set; }                  //缩口预压气缸伸出V15
            public bool SK_ZY{ get; set; }                   //缩口增压气缸伸出
            public bool KK_HC{ get; set; }                   //卡口缓存气缸缩回V16
            public bool KK_DS{ get; set; }                   //卡口顶升气缸伸出V17
            public bool KK_ZD{ get; set; }                   //卡口阻挡气缸缩回V18
            public bool SGB_CW{ get; set; }                   //进隔爆上层外气缸缩回V20
            public bool SGB_CN{ get; set; }                   //进隔爆上层内气缸缩回V21
            public bool SGB_ZD{ get; set; }                   //进隔爆上层阻挡气缸缩回V22
            public bool XGB_CN{ get; set; }                  //进隔爆下层内气缸缩回V24
            public bool XGB_ZD{ get; set; }                  //进隔爆下层阻挡气缸缩回V25
            public bool XGB_CW{ get; set; }                  //进隔爆下层外气缸缩回V26
            public bool LHYZ_ZD{ get; set; }                 //上层平移气缸缩回V27
            public bool LHYZ_SJ{ get; set; }                 //上层升降气缸缩回V28
            public bool LHYZ_MLJQ{ get; set; }               //满料盒夹取气缸伸出V29
            public bool LHYZ_KLJQ{ get; set; }               //空料盒夹取气缸伸出V30
            public int JCGBY_MoveZ{ get; set; }              //基础管Z轴
            public int JCGBY_MoveY{ get; set; }              //基础管搬运Y轴
            public int JCGBY_BJ{ get; set; }              //基础管变距  
            public int JCGSS_MoveZ{ get; set; }              //基础管上下输送轴
            public int JCGFJ_MoveX{ get; set; }              //基础管分拣X轴
            public int JCGSK_MoveY{ get; set; }              //基础管缩口Y轴
            
        }

        //自动替补机
        public struct ZDTBJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
           
            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
           

            public bool TBZJ_JCHC_1{ get; set; }             //检测缓存气缸1缩回V1
            public bool TBZJ_JCHC_2{ get; set; }             //检测缓存气缸2缩回V2
            public bool TBZJ_JCDS{ get; set; }               //检测顶升气缸伸出V3
            public bool TBZJ_JCZD{ get; set; }               //检测阻挡气缸V4
            public bool TBZJ_TBDS{ get; set; }               //替补顶升气缸V5
            public bool TBZJ_TBZD{ get; set; }               //替补阻挡气缸V6
            public bool CCDJC_XY{ get; set; }                //CCD检测下压气缸伸出V7
            public bool CCDJC_DS{ get; set; }                //CCD检测顶升气缸伸出V8
            public bool DXN_XY{ get; set; }                  //探针下压检测气缸伸出V9
            public bool DXN_DS{ get; set; }                  //固定顶升气缸伸出V11
            public bool TBLM_JZ{ get; set; }                 //取线夹爪气缸伸出V13
            public bool TBLM_KJ{ get; set; }                 //取线开夹气缸伸出V14
            public bool TBLM_DS{ get; set; }                 //载具滑台-顶升
            public bool TBLM_ZJGD_1{ get; set; }             //载具滑台-载具固定1
            public bool TBLM_ZJGD_2{ get; set; }             //载具滑台-载具固定2

            public bool TBLM_ZJZJ{ get; set; }               //取载具气缸伸出V15
            public int TBLM_QX{ get; set; }                  //取线步进
            public int TBLM_ZJ{ get; set; }                  //取载具步进
            public int TBLM_MoveX{ get; set; }               //替补龙门X
            public int TBLM_MoveY{ get; set; }               //替补龙门Y
            public int TBLM_MoveZ{ get; set; }               //空载具提升Z轴
            public int CCD_Move{ get; set; }                 //不良品相机
            

        }

        //装上盖激光打码机
        public struct JGDMZSGJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2 { get; set; }//装上盖-倍速链2
           

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
            public bool Block_6 { get; set; }
           
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
            public bool Sensor_6 { get; set; }
            
           

            public bool TBJ_DS_1{ get; set; }                //踏步顶升1-顶升
            public bool TBJ_DS_2{ get; set; }                //踏步顶升2-顶升
            public bool TBJ_DS_3 { get; set; }                //踏步顶升3-顶升
            public bool TBJ_DS_4 { get; set; }                //踏步顶升4-顶升
            public bool ZGZ_DS{ get; set; }                  //注硅脂顶升气缸伸出V3
            public bool ZGZ_DW{ get; set; }                  //注硅脂定位气缸伸出V4
            public bool ZGZ_CT{ get; set; }                  //注硅脂侧推气缸伸出V5
            public bool GKM_XY{ get; set; }                  //基础管刻码下压气缸伸出V6
            public bool GKM_DS{ get; set; }                  //基础管刻码顶升气缸伸出V7
            public bool SG_TL{ get; set; }                   //推上盖气缸伸出V8
            public bool SG_DS{ get; set; }                   //上盖顶升气缸伸出V9
            public bool SG_CTDW{ get; set; }                 //上盖侧推定位气缸伸出V10
            public bool SG_HDW{ get; set; }                  //上盖后定位气缸伸出V11
            public bool SG_HTJ{ get; set; }                  //上盖后托举气缸伸出V12
            public bool SG_YJ{ get; set; }                   //上盖组装压紧气缸伸出V13
            public bool SG_QLSS{ get; set; }                 //上盖取料伸缩气缸伸出V14
            public bool SG_QLSJ{ get; set; }                 //上盖取料升降气缸伸出V15
            public bool SG_ZJ{ get; set; }                   //上盖取料夹爪气缸伸出1V16
            public bool SG_YG{ get; set; }                   //装上盖压盖气缸伸出V20
            public bool JGKM_XY{ get; set; }                 //上盖刻码下压气缸伸出V21
            public bool JGKM_DS{ get; set; }                 //上盖刻码顶升气缸伸出V22
            public bool JGKM_CT{ get; set; }                 //上盖刻码侧推定位气缸伸出V23
            public bool KMJC_XY{ get; set; }                 //管码检测下压气缸伸出V24
            public bool KMJC_DS{ get; set; }                 //管码检测顶升气缸伸出V25
            public bool GMJC_XY{ get; set; }                 //盖码检测下压气缸伸出V26
            public bool GMJC_DS{ get; set; }                 //盖码检测顶升气缸伸出V27
            public bool KMJC_CT{ get; set; }                 //盖码检测侧推气缸伸出V28
            public bool SGB_CN{ get; set; }                  //出隔爆上层内气缸缩回V29
            public bool SGB_CW{ get; set; }                  //出隔爆上层外气缸缩回V30
            public bool SGB_ZD{ get; set; }                  //出隔爆上层阻挡气缸伸出V31
            public bool XGB_CN{ get; set; }                  //出隔爆下层内气缸缩回V42
            public bool XGB_CW{ get; set; }                  //出隔爆下层外气缸缩回V43
            public bool XGB_ZD{ get; set; }                  //出隔爆下层阻挡气缸缩回V44
            public int KMCCD_Move{ get; set; }               //基础管检测
            public int SQR_Move{ get; set; }                 //上盖刻码检
            public int ZGZ_MoveZ{ get; set; }                //注硅脂步进
            public int TBJ_YZ{ get; set; }                    //进接驳移载
            
        }

        //自动装袋机
        public struct ZDZDJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1 { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2 { get; set; }//装上盖-倍速链2
            
            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
           
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            

            public bool XCZJ_KJ_1{ get; set; }                 //左开夹气缸1
            public bool XCZJ_KJ_2{ get; set; }                 //左开夹气缸1
            public bool XCZJ_JLHC_1{ get; set; }             //进料缓存阻挡气缸1     
            public bool XCZJ_JLHC_2{ get; set; }             //进料缓存阻挡气缸2    
            public bool JB_JLYZ{ get; set; }                 //进接驳移载气缸
            public bool JB_JLDS{ get; set; }                 //进接驳顶升气缸
            public bool KZ_Move{ get; set; }                 //人工捆扎-移位气缸
            public bool ZX_XJZX{ get; set; }                 //线夹折线气缸
            public bool ZX_XJJX{ get; set; }                 //线夹夹线气缸
            public bool ZX_JSGZX{ get; set; }                //金属管折线气缸
            public bool ZX_JSGJX{ get; set; }                //金属管夹线气缸
            public bool DB_DDB{ get; set; }                  //大挡边气缸
            public bool ZX_SJ{ get; set; }                   //折线升降气缸
            public bool ZX_LRPT{ get; set; }                 //左右平推气缸
            public bool ZX_JX{ get; set; }                 //折线压线气缸 
            public bool ZX_YX{ get; set; }                 //折线压线气缸 
            public bool ZX_LPT{ get; set; }                  //左折线平推气缸
            public bool ZX_RPT{ get; set; }                  //右折线平推气缸 
            public bool DB_XDB{ get; set; }                  //小挡边气缸
            public bool ZD_FB{ get; set; }                   //制袋封边气缸
            public bool ZD_CD{ get; set; }                   //制袋裁断气缸
            public bool LD_JD{ get; set; }                   //夹袋上气缸
            public bool CKD_SXCD{ get; set; }                //撑袋上下气缸
            public bool CKD_QH{ get; set; }                  //撑袋口前后气缸
            public bool CKD_SX{ get; set; }                  //撑袋口上下气缸
            public bool CKD_LR{ get; set; }                  //撑袋口左右气缸
            public bool DD_UpDown{ get; set; }               //定袋升降气缸
            public bool DD_LR{ get; set; }                   //定袋左右气缸
            public bool ZK_LR{ get; set; }                   //抽真空左右气缸
            public bool ZK_UpDown{ get; set; }               //抽真空升降气缸
            public bool SPRD_YX{ get; set; }                 //压线气缸
            public bool SPRD_SY{ get; set; }                 //送压气缸
            public bool FK_DS{ get; set; }                   //预压顶升气缸
            public bool FK_XJ{ get; set; }                   //预压下降气缸
            public bool FK_RY{ get; set; }                   //热压左右气缸
            public bool YDYW_PZK{ get; set; }                //排真空气缸
            public bool YDYW_YW{ get; set; }                 //压袋移位气缸
            public bool YDYW_YY{ get; set; }                 //贴标预压气缸
            public bool YDYW_DS{ get; set; }               //夹袋下气缸
            public bool YZ_Up{ get; set; }               //- A线下层移载气缸：D1194（A有B无）
            public bool YZ_Down{ get; set; }               //- A线下层移载气缸：D1194（A有B无）

            public int ZJTSJ_MoveZ{ get; set; }              //空载具提升机
            public int LM_MoveX{ get; set; }                 //龙门X轴
            public int LM_MoveZ{ get; set; }                 //龙门Z轴
            public int SD_MoveX{ get; set; }                 //送袋轴
            public int LD_MoveX{ get; set; }                 //拉袋轴
            public int CD_MoveX{ get; set; }                 //撑袋轴
            public int LM_MoveY{ get; set; }                 //龙门Y轴
            public int RGKZ_MoveX{ get; set; }               //人工捆扎-移载
            public int TBPD_Rota{ get; set; }                //贴标皮带-步进机
            public int ZD_Rota{ get; set; }                  //制袋 伺服
            public int ZJYZ_UpMove{ get; set; }              //- 载具移栽-上层移载：D5768(B有A无)
            public int ZJYZ_DownMove{ get; set; }              //- 载具移栽-下层移载：D5768(B有A无)

            public bool Belt_Up_ZJ{ get; set; }              //进料载具输送步进
            public bool Belt_Down_ZJ{ get; set; }            //回流载具输送步进
            public bool Belt_PD{ get; set; }                 //成品皮带步进电机

            
        }

        //装箱贴标机
        public struct ZXTBJ_PLC_ActionDataModel
        {
            public bool Belt_Up_1_F { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_1_B { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2_F { get; set; }//载具旋转缓存-上层倍速链
            public bool Belt_Up_2_B { get; set; }//装上盖-倍速链2
            public bool Belt_Up_3_F { get; set; }//装上盖-倍速链3
            public bool Belt_Up_3_B { get; set; }//装上盖-倍速链3
            public bool Belt_Up_4_F { get; set; }//装上盖-倍速链3
            public bool Belt_Up_4_B { get; set; }//装上盖-倍速链3
            public bool Belt_Up_5 { get; set; }//装上盖-倍速链3
            public bool Belt_Up_6 { get; set; }//装上盖-倍速链3
            public bool Belt_Up_7 { get; set; }//装上盖-倍速链3
            public bool Belt_Up_8 { get; set; }//装上盖-倍速链3
            public bool Belt_Up_9 { get; set; }//装上盖-倍速链3
            public bool Belt_Up_10 { get; set; }//装上盖-倍速链3

            public bool Block_1 { get; set; }//阻挡
            public bool Block_2 { get; set; }
            public bool Block_3 { get; set; }
            public bool Block_4 { get; set; }
            public bool Block_5 { get; set; }
            public bool Block_6 { get; set; }
            public bool Block_7 { get; set; }
            public bool Block_8 { get; set; }
            public bool Block_9 { get; set; }
            public bool Block_10 { get; set; }
            
            public bool Sensor_1 { get; set; }//感应器
            public bool Sensor_2 { get; set; }
            public bool Sensor_3 { get; set; }
            public bool Sensor_4 { get; set; }
            public bool Sensor_5 { get; set; }
            public bool Sensor_6 { get; set; }
            public bool Sensor_7 { get; set; }
            public bool Sensor_8 { get; set; }
            public bool Sensor_9 { get; set; }
            public bool Sensor_10 { get; set; }
           

            //气缸
            public bool FYZB_SSDW{ get; set; }               //硬纸板输送定位气缸
            public bool ZX_ZXDW{ get; set; }                 //装箱定位气缸
            public bool ZX_JMDW{ get; set; }                 //检码定位气缸
            public bool ZX_DW{ get; set; }                   //装箱转角定位气缸
            public bool FJ_DW{ get; set; }                   //装箱转角定位气缸
            public bool CL_DW{ get; set; }                   //- 出料-定位：(A有B无)
            public bool GBM_ZB{ get; set; }                  //放硬纸板到装箱隔爆门气缸
            public bool GBM_HGZ{ get; set; }                 //装箱到放合格证隔爆门气缸
            public bool QYZB_UpDown{ get; set; }             //取硬纸板升降气缸
            public bool ZX_ZD{ get; set; }                   //装箱阻挡气缸
            public bool JM_ZD{ get; set; }                   //检码阻挡气缸
            public bool QHGZ_UpDown{ get; set; }             //取硬纸板吸真空
            public bool QHGZ_DS{ get; set; }                 //分拣-顶升
            public bool CZ_DS_1{ get; set; }             //称重-顶升1
            public bool CZ_DS_2{ get; set; }             //称重-顶升2
            public bool CZ_ZD{ get; set; }             //称重-顶升2
            public bool QYZB_ZK{ get; set; }                 //取硬纸板吸真空
            public bool GBM_NG{ get; set; }                 //人工捆扎出料隔爆门
            public bool GBM_CA{ get; set; }                 //(A线)出A线隔爆门


            //轴目标位置
            public int ZB_MoveX{ get; set; }                 //取硬纸板横移轴
            public int ZBTBJ_MoveZ{ get; set; }              //硬纸板提升步进
            public int ZBLX_MoveZ{ get; set; }               //硬纸板输送旋转步进
            public int ZX_XZ{ get; set; }                    //装箱旋转步进
            public int ZX_JMXZ{ get; set; }                  //检码旋转步进
            public int ZX_ZJXZ{ get; set; }                  //装箱转角旋转步进

            public int HGZ_ZJXZ{ get; set; }                  //合格证-升降步进
            public int FJ_XZ{ get; set; }                  //分拣旋转-旋转步进
            public int CL_XZ{ get; set; }                  //出料旋转-旋转步进
            public int SMS_TSZ{ get; set; }                  //说明书-提升机
            public int CP_XZ{ get; set; }                  //成品皮带-步进机
            public int CP_ZL{ get; set; }                  //机器人抓料-步进机
            public int QHGZ_MoveX{ get; set; }             //取合格证说明书-横移

        }
        //机械手
        public struct JXS_PLC_ActionDataModel
        {
            public bool Signal_Auto { get; set; }            //机器人联机信号-自动状态
            public bool Signal_PutUp { get; set; }           //机械手去产品位
            public bool Signal_PutDown { get; set; }         //机械手去放产品位
            public bool Signal_Standby { get; set; }    //机械手去待机位
            public bool Signal_Clear_Ready { get; set; }     //清除码垛信号
            public bool Signal_Stack_Finish { get; set; }    //机器人码垛完成信号
            public bool Signal_Take_Standby { get; set; }     //机器人到待机位
            public bool Signal_Take_Start { get; set; }     //机器人到取产品位
            public bool Signal_Take_End { get; set; }     //机器人到放产品位
            public bool Signal_Alarm { get; set; }           //机器人报警
        }
        //组批间机械手
        public struct JXS_ZPJ_PLC_ActionDataModel
        {
            public int Signal_Auto { get; set; }            //机器人联机信号-自动状态0待机中、1暂停中、2启动中、3取料中、4取料完成、5放料中、6A车放料完成、7B车放料完成、9告警状态
            public int Signal_PutDown { get; set; }           //0放A车、1放B车、2放C车
        
        }
        //开箱机
        public struct KXJ_PLC_ActionDataModel
        {
            public bool Belt_ZB_F;              //硬纸板输送皮带步进正转
            public bool Belt_ZB_B;              //硬纸板输送皮带步进反转

            public bool Belt_KX_Finish;          //开箱机完成信号
            public bool Belt_KX_Alarm;           //开箱机报警信号
            public bool Belt_KX_Standby;         //开箱机就绪信号
            public bool Belt_KX_Start;           //开箱机启动信号
        }

        //封箱打带机
        public struct FXDDJ_PLC_ActionDataModel
        {
            public bool Belt_CZ;                //称重滚筒步进
            public bool Belt_FL_B;              //分料皮带步进反转
            public bool Belt_FL_F;              //分料皮带步进正转
            public bool Belt_CL_B;              //出料皮带步进反转
            public bool Belt_CL_F;              //出料皮带步进正转
            public bool Belt_JB_BA;             //B-A接驳皮带防爆电机
            public bool Belt_FL_XZ;             //分料旋转步进原点

            public bool Belt_FX_Finish;         //封箱机完成信号
            public bool Belt_FX_Alarm;          //封箱机报警信号
            public bool Belt_FX_Standby;        //封箱机就绪信号
            public bool Belt_FX_Start;          //封箱机启动信号

            public int HGZ_ZJXZ;                //合格证升降步进
            public int FL_XZ;                   //分料旋转步进
            public int CL_XZ;                   //出料旋转步进
            public bool HGZ_ZJXZ_RunFlag;       //合格证升降步进运行标志位
            public bool FL_XZ_RunFlag;          //分料旋转步进运行标志位
            public bool CL_XZ_RunFlag;          //出料旋转步进运行标志位

            public bool FL_DW;                  //分料定位气缸
            public bool CL_DW;                  //出料定位气缸
            public bool GBM_CA;                 //出A线隔爆门气缸
            public bool QHGZ_UpDown;            //取合格证升降气缸
            public bool QHGZ_HY;                //取合格证横移气缸
            public bool CZ_DS_1;                //称重气缸1
            public bool CZ_DS_2;                //称重气缸2
            public bool CZ_ZD;                  //称重阻挡气缸
            public bool QHGZ_ZK;                //取合格证吸真空

            public int HGZ_ZJXZ_Now;            //合格证升降步进当前位置
            public int FL_XZ_Now;               //分料旋转步进当前位置
            public int CL_XZ_Now;               //出料旋转步进当前位置

            public bool Belt_Out1;              //包装伸缩皮带信号伸出采集
            public bool Belt_In1;               //包装伸缩皮带信号缩回采集
            public bool Belt_SS1;               //包装伸缩皮带信号输送采集
            public bool Belt_GY1;               //包装伸缩皮带信号有料采集
            public bool Belt_Out2;              //出货伸缩皮带信号伸出采集
            public bool Belt_In2;               //出货伸缩皮带信号缩回采集
            public bool Belt_SS2;               //出货伸缩皮带信号输送采集
            public bool Belt_GY2;               //出货伸缩皮带信号有料采集
        }

       

        //长输送线
        public struct CSSX_PLC_ActionDataModel
        {
            public bool Belt_DW_SH1;            //出货定位气缸1缩回感应
            public bool Belt_DW_SH2;            //出货定位气缸2缩回感应
            public bool Belt_JB_DS2;            //出C线接驳皮带对射感应2
            public bool Belt_CH;                //出货感应器
            public bool Belt_CGBF_SH;           //出钢板房隔爆门气缸缩回感应
            public bool Belt_CGBF_SC;           //出钢板房隔爆门气缸伸出感应 
            public bool Belt_CCJ_SH;            //出车间隔爆门气缸缩回感应
            public bool Belt_CCJ_SC;            //出车间隔爆门气缸伸出感应
            public bool Belt_SS1;               //皮带输送感应1
            public bool Belt_SS6;               //皮带输送感应6
            public bool Belt_SS7;               //皮带输送感应7
            public bool Belt_SS8;               //皮带输送感应8
            public bool Belt_GBM_C_SH;          //出C线隔爆门气缸缩回感应
            public bool Belt_GBM_C_SC;          //出C线隔爆门气缸伸出感应
            public bool Belt_JB_DS1;            //出C线接驳皮带对射感应1

            public bool Belt_CHPD_BJ_B;         //出货皮带步进反转
            public bool Belt_CHPD_BJ_F;         //出货皮带步进正转
            public bool Belt_CHPD_FB1;          //出货皮带防爆电机1
            public bool Belt_CHPD_FB2;          //出货皮带防爆电机2
            public bool Belt_CHPD_FB3;          //出货皮带防爆电机3
            public bool Belt_CHPD_FB4;          //出货皮带防爆电机4
            public bool Belt_CHPD_FB5;          //出货皮带防爆电机5
            public bool Belt_CHPD_FB6;          //出货皮带防爆电机6
            public bool Belt_CHPD_FB7;          //出货皮带防爆电机7
            public bool Belt_CHPD_FB8;          //出货皮带防爆电机8
            public bool Belt_CHPD_DWSC;         //出货定位气缸伸出

            public bool Belt_SS2;               //皮带输送感应2
            public bool Belt_SS3;               //皮带输送感应3
            public bool Belt_SS4;               //皮带输送感应4
            public bool Belt_SS5;               //皮带输送感应5
            public bool Belt_QCZ_DW;            //皮带输送1前出站到位感应

            public int CL_XZ;                   //出料旋转-旋转步进
            public int CL_XZ_Now;               //出料旋转-旋转步进当前位置
            public bool CL_XZ_RunFlag;          //出料旋转-旋转步进运行标志位
        }
        #endregion
        //绕线机


        //任务信息
        public struct RWTakeDataModel
        {
            public string lineId;               //生产线ID
            public string taskNum;              //任务编号
            public string taskTime;             //生产日期
            public string startBoxNum;          //起始盒号
            public string boxSpec;              //装盒规格
            public string featureCode;          //特征码/机手号
            public string length;               //脚线长度
            public int produceTotal;            //生产总数量
            public int currentTotal;            //已生产数量
            public string produceBatch;         //生产批次
        }

        //任务台账信息
        public struct RWTakeInfoDataModel
        {
            public string lineId;               //生产线ID
            public string taskNum;              //任务编号
            public string taskTime;             //生产日期
            public string startCaseNum;         //起始盒号
            public string startBoxNum;          //起始箱号
            public int    boxSpec;              //装箱规格
            public int    caseSpec;             //装盒规格
            public string weight;               //每箱重量
            public string featureCode;          //特征码/机手号
            public string length;               //脚线长度
            public string goodsCode;            //物品类码
            public string produceBatch;         //生产批次
            public string corporationCode;      //企业代码
            public string corporationName;      //企业名称
            public string sectionMask;          //段别标志
            public string detonatorName;        //雷管名称
            public string material;             //材质
            public string power;                //威力
            public string category;             //类别
            public string notes;                //备注
            public string permit;               //许可证
            public string FactoryModel;         //芯片厂家
            public int SIDTaskNum;              //生产总数
            public int SIDCompleteNum;          //已生产数量
            public string CurrentTime;          //当前生产日期
            public int ShengYuQty;              //剩余数量（生产前更新一次，作 当天总生产数 使用，主要用在昨天的创建的任务在今天继续使用）
        }
        //报表
        public struct ReportDataModel
        {
            public int targetCT;                //DW目标CT_100
            public int GoodProductCount;        //DW良品计数
            public int nonGoodProductCount;     //DW不良品计数
            public short alarmCount;            //报警次数_W
            public short[] ctCount;             //CT_10次100MW
            public short ctAVCount;             //平均CT_100_W
            public short[] runTimeStat;         //运行时间统计MW
            public short[] workTimeStat;        //稼动时间统计MW
            public short[] waitTimeStat;        //待料时间统计MW
            public short[] alarmTimeStat;       //报警时间统计MW
            public short[] stopTimeStat;        //停止时间统计MW
            public int workRate;                //稼动率0．1％DW
            public int nonGoodRate;             //不良率0．1％DW
        }

        //三色灯
        public struct TricolourlightDataModel
        {
            public bool green;                  //绿灯
            public bool red;                    //红灯
            public bool yellow;                 //黄灯
        }

        //第三方西门子基础管
        public struct SiemensS7_JCG_DataModel
        {
            public ushort JCG_Total;            //基础管总数
            public ushort JCG_Surplus;          //基础管剩余数
        }
       

        /// <summary>
        /// PLC状态数据
        /// </summary>
        public class PlcStatus
        {
            public string ip { get; set; } //设备ip地址
            public int port { get; set; }//端口
            public int[] portList { get; set; }//端口列表
            public string plcName { get; set; }//PLC的名称可用唯一ID
            public bool status { get; set; }//状态（true代表连接成功，false代表连接失败）
            public int connectCount { get; set; }//连接次数
        }
        // plc信息数据
        public class PlcData
        {
            public string plcId { get; set; }//PLC的id
            public List<deviceData> relevance { get; set; }//关联的设备信息
        }

        //设备信息数据
        public class deviceData
        {
            public string deviceId { get; set; }//设备的id
            public string deviceName { get; set; }//设备名称
            public string dataType { get; set; }//数据类型：（Action(设备运动量)、Alarm(告警数据)、Report（设备报表数据））
            public string topic { get; set; }//订阅主题
       
        }
        private static readonly Regex _regex = new Regex(@"^[^0-9]*(\d+(?:\.\d+)?).*");//匹配开头的非数字字符（跳过字母等）。

        // 装置配置项
        public class PlcPart
        {

            public string PartName { get; set; }
            public string PartAddress { get; set; }
            public string PartType { get; set; }
            public int PartAddressValue()
            {
                var match = _regex.Match(PartAddress);
                return match.Success ? int.Parse(match.Groups[1].Value) : Convert.ToInt16(PartAddress.Substring(1));//获取元素地址，如：D1000=>1000
                //return  Convert.ToInt16(Element.Substring(2));//获取元素地址
            }
        }
        /// <summary>
        /// 装置配置信息
        /// </summary>
        public class ModuleConfig
        {
            public string ModuleType { get; set; }//模块类型Cylinder、Motor、Axle
            public string StartAddress { get; set; }//起始地址
            public string EndAddress { get; set; }//结束地址
            public List<PlcPart> PartList { get; set; }//装置列表
            public int EndAddressValue()
            {
                var match = _regex.Match(EndAddress);
                return match.Success ? int.Parse(match.Groups[1].Value) : Convert.ToInt16(EndAddress.Substring(1));//获取元素地址
                //return  Convert.ToInt16(Element.Substring(2));//获取元素地址
            }
            public int StartAddressValue()
            {
                var match = _regex.Match(StartAddress);
                return match.Success ? int.Parse(match.Groups[1].Value) : Convert.ToInt16(StartAddress.Substring(1));//获取元素地址
                //return  Convert.ToInt16(Element.Substring(2));//获取元素地址
            }
            /// <summary>
            /// 获取长度（起始到结束长度）
            /// </summary>
            /// <returns></returns>
            public int GetSize()
            {
                return EndAddressValue() - StartAddressValue() + 1;
            }
            
            /// <summary>
            /// 获取地址列表
            /// </summary>
            /// <returns></returns>
            public string[]  GetAddressList()
            {
                if (PartList==null)
                {
                    return null;
                }

                if (PartList.Count < 0)
                {
                    return null;
                }
                return PartList.Select(part =>  part.PartAddress).ToArray();
            }
        }
        /// <summary>
        /// 工位节点
        /// </summary>
        public class ElementConfig
        {
            public string ElementName { get; set; }//设备名称
            public string DeviceId { get; set; }//设备ID

            public string DataType
            {
                get
                {
                    return DeviceId.Split('_')[0];
                }
            } //设备类型

            public string Topic { get; set; }//订阅主题
            public string AlarmConfigFilePath { get; set; }//告警配置表
            public bool Enabled { get; set; }//是否启用
            public List<ModuleConfig> ModuleConfig { get; set; }//标志位plc地址
        }
        /// <summary>
        /// PLC服务配置
        /// </summary>
        public class PlcServerConfig
        {
            public string Ip { get; set; }//PLC地址
            public int Port { get; set; }//PLC端口
            public int[] PortList { get; set; }//PLC端口列表
            public string PlcName { get; set; }//PLC名称
            public string PlcType { get; set; }//PLC类型
            public string PlcModel { get; set; }//PLC型号
            public string HeartBeatAddress { get; set; }//心跳地址
            public int HeartBeatMaxTime { get; set; }//心跳最大时间
            public bool Enabled { get; set; }//是否启用
            public List<ElementConfig> ElementConfig { get; set; }//元素配置（plc实现的业务）
        }
        /// <summary>
        /// appsettings配置文件
        /// </summary>
        public class AppSettings
        {
            public ConnectionStrings ConnectionStrings { get; set; }//数据库配置
            public Redis Redis { get; set; }//redis配置
            public DebugSetting DebugSetting { get; set; }//调试设置
            public List<PlcServerConfig> PlcServer { get; set; }//多个PLC服务
            /// <summary>
            /// 获取PLC服务
            /// </summary>
            /// <param name="plcName"></param>
            /// <returns></returns>
            public PlcServerConfig GetPlcServer(string plcName)
            {
                return PlcServer.FirstOrDefault(x => x.PlcName == plcName);
            }
        }
        /// <summary>
        /// AppSetting配置表
        /// </summary>
        public class ConnectionStrings
        {
            public string MESConnection { get; set; }//mes数据库配置
            public List<string> MysqlConnstr { get; set; }//生产数据库配置
         
            
        }

        public class Redis
        {
            public string ConnectionStrings { get; set; }
        }

        public class DebugSetting
        {
            public bool EnabledMenuSetting { get; set; }
            public bool EnabledRWDebug { get; set; }
        }
        /// <summary>
        /// 动作配置
        /// </summary>
        public class ActionAddressConfig
        {
            public string Address { get; set; }            //地址
            public ushort Length { get; set; }             //读取长度
            public AddressType AddressType { get; set; }   //地址类型
        }
        public enum AddressType
        {
            _short,
            _int,
            _bool,
            _string,
        }
        /// <summary>
        /// 告警配置项
        /// </summary>
        public class AlarmAddressConfig
        {
            public string alarmId { get; set; }             //告警Id  
            public string alarmContan { get; set; }         //告警内容  
            public string addressType { get; set; }         //数据类型D、x、y 
            public string trigger { get; set; }         //触发条件  

        }
        /// <summary>
        /// 告警数据
        /// </summary>
        public class AlarmData
        {
            public string deviceID { get; set; }          //  设备id
            public string faultID { get; set; }           // 告警id
            public string alarmContan { get; set; }         //告警内容
            public int alarmLevel { get; set; }             //告警等级 
            public long alarmTime { get; set; }             //时间戳
            public int status { get; set; }             // 状态（0代表未触发，1代表触发）
            public DateTime createdTime { get; set; }   // 告警时间
        }
    }
}
